import{FastError as t}from"../error/index.mjs";const e={hexToRgb(e){let r="";if(!/^#?[0-9A-F]{6}$/i.test(e))throw new t("输入错误的hex");r=(e=e.replace("#","")).match(/../g);for(let t=0;t<3;t++)r[t]=parseInt(r[t],16);return r},rgbToHex(e,r,o){const n=/^\d{1,3}$/;if(!n.test(e)||!n.test(r)||!n.test(o))throw new t("输入错误的rgb颜色值");const h=[e.toString(16),r.toString(16),o.toString(16)];for(let t=0;t<3;t++)1===h[t].length&&(h[t]=`0${h[t]}`);return`#${h.join("")}`},getDarkColor(e,r){if(!/^#?[0-9A-F]{6}$/i.test(e))throw new t("输入错误的hex颜色值");const o=this.hexToRgb(e);for(let t=0;t<3;t++)o[t]=Math.round(20.5*r+o[t]*(1-r));return this.rgbToHex(o[0],o[1],o[2])},getLightColor(e,r){if(!/^#?[0-9A-F]{6}$/i.test(e))throw new t("输入错误的hex颜色值");const o=this.hexToRgb(e);for(let t=0;t<3;t++)o[t]=Math.round(255*r+o[t]*(1-r));return this.rgbToHex(o[0],o[1],o[2])}};export{e as colorUtil};
//# sourceMappingURL=index.mjs.map
